package com.example.eschool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.eschool.R;
import com.example.eschool.bean.Message;

import java.util.List;

public class messageAdapter extends ArrayAdapter {
    public messageAdapter(@NonNull Context context, int resource, @NonNull List objects) {
        super(context, resource, objects);
    }
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Message message= (Message) getItem(position);//得到当前项的 Fruit 实例
        //为每一个子项加载设定的布局
        View view= LayoutInflater.from(getContext()).inflate(R.layout.message_item,parent,false);

        //分别获取 的实例

        TextView title=view.findViewById(R.id.title);
        TextView messages=view.findViewById(R.id.message);
        TextView price=view.findViewById(R.id.price);
        TextView time=view.findViewById(R.id.time);

        // 设置要显示的图片和文字
        title.setText(message.getTitle());
        messages.setText(message.getMessage());
        price.setText(message.getPrice());
        time.setText(message.getTime());

        return view;
    }
}
